﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Spinning.Spinning.Unitity;
using Spinning.Spinning.Scenes.ProcessScene.Items;
using Microsoft.Xna.Framework.Input.Touch;
using Spinning.Spinning.Interface;

namespace Spinning.Spinning.Entity.Scenes
{
    class ItemScene : BaseScene, ISaveLoad
    {
        SubSceneInItemsScene sub;
        public override void OnLoad()
        {
            base.OnLoad();
            Sprite backGroundSprite = new Sprite();
            backGroundSprite.textureName = "bg";
            backGroundSprite.ZIndex = Constants.background;
            backGroundSprite.OnLoad();
            this.Attach(backGroundSprite);

            Sprite itemTitleSprite = new Sprite();
            itemTitleSprite.textureName = "item_store/txt_items";
            itemTitleSprite.ZIndex = Constants.ui;
            itemTitleSprite.OnLoad();
            itemTitleSprite.Position = new Vector2(170, 60);
            this.Attach(itemTitleSprite);

            Sprite barSprite = new Sprite();
            barSprite.textureName = "item_store/bar";
            barSprite.ZIndex = Constants.uibackground;
            barSprite.OnLoad();
            barSprite.Position = new Vector2(75, 40);
            this.Attach(barSprite);

            

            //31 171

            sub = new SubSceneInItemsScene();
            sub.Position = new Vector2(31,171);
            sub.Color = Color.Transparent;
            sub.ZIndex = Constants.ui;
            sub.OnLoad();
            Attach(sub);

            ButtonSprite backSprite = new ButtonSprite();
            backSprite.textureName = "p2/back";
            backSprite.ZIndex = Constants.ui;
            backSprite.Position = new Vector2(385, 695);
            backSprite.OnLoad();
            TouchManager.RegisteTouchArea(backSprite);
            this.Attach(backSprite);
            backSprite.OnTouchEvent += OnBackTouch;

        }

        void OnBackTouch(BaseEntity entity, TouchLocation touchLocation)
        {
            Game1.stageManager.GoToScene("role");
        }

        public override BaseScene Clone()
        {
            ItemScene scene = new ItemScene();
            scene.Size = new Vector2(Constants.Window_Width, Constants.Window_Height);
            scene.OnLoad();
            scene.SortChildren();
            scene.Load(Game1.stageManager.GameSrate);
            return scene;
        }

        public void Save(Unitity.Storage.SaveData state)
        {
            //sub.Save(state);
        }

        public void Load(Unitity.Storage.SaveData state)
        {
            //sub.Load(state);
        }
    }
}
